import request from '../apiconfig';
import utils from '../utils/util';

async function template({url, method, data, success}) {
  try {
    utils.showLoading();
    const res = await request({url, method, data});
    return typeof success === 'function' ? success(res) : res.data;
  } catch (e) {
    throw e;
  } finally {
    utils.hideLoading()
  }

}

export default template;
